<template>
    <div class="diglog-info streetEdit projectDialog">
        <el-dialog title="编辑" :visible.sync="dialogVisible" size='small'>
            <el-tabs>
                <el-tab-pane label="项目信息">
                    <el-form :model="dataAll" :rules="rules" ref="dataAll" label-width="0" class="demo-ruleForm">
                        <div v-if="dataAll" class="zui-noFloat">
                            <el-row :gutter="80">
                                <el-col :span="12">
                                    <el-form-item prop="name">
                                        <div class="content">
                                            <my-tooltip text="地块编码"></my-tooltip>
                                              <div class="desc-input">
                                                 <el-input  v-model="dataAll.name" placeholder="请输入项目名称"></el-input>
                                              </div>
                                        </div>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="24">
                                    <el-form-item>
                                        <div class="content">
                                            <my-tooltip text="地块名称"></my-tooltip>
                                              <div class="desc-input">
                                                 <el-input v-model="dataAll.address" type="textarea" placeholder="请输入建设内容及规模"></el-input>
                                              </div>
                                        </div>
                                    </el-form-item>
                                </el-col>
                                 <el-col :span="12">
                                    <el-form-item>
                                        <div class="content">
                                            <my-tooltip text="地块面积"></my-tooltip>
                                            <div class="desc-input">
                                                 <el-input v-model="dataAll.personName" placeholder="请输入投资金额"></el-input>
                                            </div>
                                        </div>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item>
                                        <div class="content">
                                            <my-tooltip text="地块属性"></my-tooltip>
                                            <el-select class="desc-input" v-model="dataAll.areaId" placeholder="请选择">
                                            <el-option  v-for="item in areaList" :key="item.id" :label="item.name" :value="item.id">
                                            </el-option>
                                            </el-select>
                                        </div>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item>
                                        <div class="content">
                                            <my-tooltip text="土地所属"></my-tooltip>
                                            <div class="desc-input">
                                                 <el-input  v-model="dataAll.location" placeholder="请输入施工单位名称"></el-input>
                                            </div>
                                        </div>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item>
                                        <div class="content">
                                            <my-tooltip text="标注"></my-tooltip>
                                            <div class="desc-input">
                                                 <el-input  v-model="dataAll.location" placeholder="请输入施工单位联系电话"></el-input>
                                            </div>
                                        </div>
                                    </el-form-item>
                                </el-col>
                                 <el-col :span="12">
                                    <el-form-item prop="areaId">
                                        <div class="content">
                                            <my-tooltip text="地块类型"></my-tooltip>
                                            <el-select class="desc-input" v-model="dataAll.areaId" placeholder="请选择">
                                            <el-option  v-for="item in areaList" :key="item.id" :label="item.name" :value="item.id">
                                            </el-option>
                                            </el-select>
                                        </div>
                                    </el-form-item>
                                </el-col>
                                
                            </el-row>
                            <div style="text-align:left; margin-left:100px;">
                              <el-button type="primary" @click="upate('dataAll')" style="width:130px">保存</el-button>
                              <el-button @click="dialogVisible = false" style="width:130px;margin-left:20px">取消</el-button>
                            </div>
                        </div>
                    </el-form>
                </el-tab-pane>
            </el-tabs>
        </el-dialog>
    </div>
</template>
<script>
export default {
    props: ['showDialogId'],
    created() {
        this.ajax({
                url: 'tProjectLand/selectProjectLandById',
                data: {
                    id: this.showDialogId
                }
            }).then(data => {
                this.dataAll = data
            })
//      this.ajax({
//              url: 'Area/GetByParentCode',
//              data: {
//                  parentCode: "511500"
//              }
//          }).then(data => {
//              this.areaList = data
//      })
//    
    },
    mounted() {

    },
    watch: {
        dialogVisible(val) {
            this.$emit('update:showDialog', val)
        }
    },
    data() {
        return {
            dialogVisible: true, //弹出框隐藏显示
            options: [],
            value: '',
            dataAll: {
            },
            areaList:[],
            rules:{
             name: [{ required: true, message: '街道名称不能为空', trigger: 'blur' }],
             areaId: [{ required: true, message: '所属区域不能为空', trigger: 'blur' }]
            },
        }
    },
    methods: {
        show(row) {
            this.dialogVisible = !this.dialogVisible
        },
        upate(formName) {
             if (this.dataAll.areaId != "" && this.dataAll.areaId != null) {
                    let AreaName = this.areaList.find((item) => {
                        return item.id === this.dataAll.areaId;
                        });
                    this.dataAll.areaName = AreaName.name
            }
            this.$refs[formName].validate((valid) => {
            if (valid) {
                 this.ajax({
                            url: 'Point/Update',
                            type: 'post',
                            contentType: "application/json; charset=utf-8",
                            data: JSON.stringify(this.dataAll),
                            type: 'post',
                            showMessage: '修改成功'
                        }).then(data => {
                              /*向上传递修改成功的信息*/
                           this.eventBus.$emit('streetUpdate')
                           this.dialogVisible = false
                        })
                    }
                });
        }
    },
    components: {

    }
}
</script>
<style lang="less">
    .streetEdit .el-form-item__error{
        top:35px;
        left:100px;
     }
    .streetEdit .el-form-item{
        min-height: 50px;
        margin-bottom: 5px;
    }
</style>
<style scoped lang="less">
    .zui-noFloat .el-col
    {
    float:none;
    display:inline-block;
    margin-right: -4px;
    vertical-align: top;
  }
  .projectDialog .desc-input{
    width:70%;
    float:left;
  }
</style>
